import struct

fbook = open("C:\\Users\\17591\\Desktop\\we.txt",encoding ='utf8')
book= fbook.read()

position = fbook.seek(0, 0)

dot_char_num = 16*16/8
ffont= open('C:\\Users\\17591\\Desktop\\sun.bin','rb')


def get_dot_info(file_font,ral_unicode_position,char_num):
    dot_position = ral_unicode_position*dot_char_num

    file_font_position = file_font.seek(int(dot_position),0)
    dot_infomation = file_font.read(int(char_num))

    return dot_infomation

for ch in fbook.read():

    print(ord(ch))
    dot_info = get_dot_info(ffont,ord(ch)-0x4E00, dot_char_num)
    #dot_info = get_dot_info(ffont,ord(ch), dot_char_num)
    
    for ch in dot_info:
        print("0x"+'{:0>2x}'.format(ch)+" ",end="")
       # print(hex(ch)+" ", end="")
    print()
    

    for index,ch in enumerate(dot_info):
        if (index%2 == 0):
            print(" ")
        print('{:08b}'.format(ch),end="")

    

fbook.close()
ffont.close()
